package top.soulblack.purchasesale.converter;

import org.springframework.beans.BeanUtils;
import top.soulblack.purchasesale.model.DTO.OrderDTO;
import top.soulblack.purchasesale.model.OrderMaster;
import top.soulblack.purchasesale.model.VO.OrderVO;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: 韦溜溜
 * @Description:
 * @Date: Create in 11:34 2019/7/22
 */
public class OrderDTOToOrderVO {

    public static List<OrderVO> converter(List<OrderDTO> orderDTOList) {
        List<OrderVO> orderVOList = new ArrayList<>();
        orderDTOList.forEach(orderDTO -> {
            orderDTO.getOrderDetailList().forEach(orderDetail -> {
                OrderVO orderVO = new OrderVO();
                OrderMaster orderMaster = new OrderMaster();
                BeanUtils.copyProperties(orderDTO, orderMaster);
                orderVO.setOrderDetail(orderDetail);
                orderVO.setOrderMaster(orderMaster);
                orderVO.setOutStoreName(orderDTO.getOutStoreName());
                orderVO.setInStoreName(orderDTO.getInStoreName());
                orderVOList.add(orderVO);
            });
        });
        return orderVOList;
    }


}
